package com.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crm.pojo.common.BaseProperties;
import com.crm.pojo.domain.Contract;
import com.crm.pojo.dto.ActivityStatisticsDto;
import com.crm.pojo.dto.CluesStatisticsDto;
import com.crm.pojo.dto.ContractQueryDto;
import com.crm.pojo.dto.ContractStatisticsListDto;
import com.crm.pojo.vo.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface ContractMapper extends BaseMapper<Contract> {
    /**
     * 分页查询合同列表
     *
     * @param page
     * @param dto
     * @return
     */
    Page<ContractVo> pageQuery(Page page, @Param("dto") ContractQueryDto dto);

    Page<ContractDetailVo> getContractDetailPage(Page page, @Param("csdto") ContractStatisticsListDto contractStatisticsListDto);

    Page<DeptStatisticsVo> getDeptStatisticsList(Page page, String beginCreateTime, String endCreateTime, BaseProperties pro);

    Page<CluesStatisticsVo> getCluesStatisticsList(Page<CluesStatisticsVo> page, @Param("cldto") CluesStatisticsDto cluesStatisticsDto);

    Page<ActivityStatisticsVo> getActivityStatisticsList(Page<ActivityStatisticsVo> page, @Param("asdto") ActivityStatisticsDto activityStatisticsDto);

    /**
     * 获取合同详情
     *
     * @param id
     * @return
     */
    ContractDetailVo getContractDetail(@Param("id") Integer id);

    @MapKey("date")
    List<Map<String, Object>> getContractStatistics(@Param("beginCreateTime") LocalDateTime beginCreateTime, @Param("endCreateTime") LocalDateTime endCreateTime);

    @MapKey("date")
    List<SubjectStatisticsVo> getSubjectStatistics(@Param("beginCreateTime") LocalDateTime beginCreateTime, @Param("endCreateTime") LocalDateTime endCreateTime);

    @MapKey("date")
    List<Map<String, Object>> getSalesStatistics(@Param("beginCreateTime") LocalDateTime beginCreateTime, @Param("endCreateTime") LocalDateTime endCreateTime);

    @MapKey("date")
    List<Map<String, Object>> getCluesStatistics(@Param("beginCreateTime") LocalDateTime beginCreateTime, @Param("endCreateTime") LocalDateTime endCreateTime);


    void add(Contract contract);
}
